import 'package:catsao/util/stirngs_helper.dart';
import 'package:flutter/material.dart';

import 'drawer_page.dart';
import 'news_page.dart';

class HomePageTopTabBar extends StatefulWidget {

  HomePageTopTabBar({Key key}):super(key:key);

  @override
  State<StatefulWidget> createState() {
    return new _HomePageTopTabBar();
  }
}

class _HomePageTopTabBar extends State<HomePageTopTabBar> {

  @override
  Widget build(BuildContext context) {
    final List<Text> tabTexts = <Text>[
      new Text(StringResources.TAB_TOP_CN,
          style: new TextStyle(fontSize: 20.0)),
      new Text(StringResources.TAB_QYZZ_CN, style: new TextStyle(fontSize: 20.0)),
      new Text(StringResources.TAB_HQZX_CN, style: new TextStyle(fontSize: 20.0)),
      new Text(StringResources.TAB_WPTJ_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_YL_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_TY_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_JS_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_KJ_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_CJ_CN, style: new TextStyle(fontSize: 20.0)),
      // new Text(StringResources.TAB_SS_CN, style: new TextStyle(fontSize: 20.0))
    ];
    final List<Tab> tabs = [];
    for (int i = 0; i < tabTexts.length; i++) {
      tabs.add(new Tab(
        child: tabTexts[i],
      ));
    }
    return new Scaffold(
      body: DefaultTabController(
          length: tabs.length,
          child: new Scaffold(
            appBar: new AppBar(
              title: new Text("头条"),
              bottom: new TabBar(
                isScrollable: true,
                tabs: tabs,
              ),
            ),
            body: TabBarView(
                children: tabTexts.map((Text tab) {
              return new Center(
                  child: new NewsPage(
                tabName: tab.data,
              ));
            }).toList()),
            drawer: new DrawerPage(),
          )),
    );
  }
}
